package com.example.mobile2021606185zhn0511homework;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.ImageView;
import android.widget.TextView;

import androidx.annotation.NonNull;
import androidx.recyclerview.widget.RecyclerView;

import java.util.List;

public class MineAdapt extends RecyclerView.Adapter<MineAdapt.ViewHolder> {

    private List<Mine> list;
    public MineAdapt(List<Mine> list){
        this.list = list;
    }



    @NonNull
    @Override
    public ViewHolder onCreateViewHolder(@NonNull ViewGroup parent, int viewType) {
        View view = LayoutInflater.from(parent.getContext()).inflate(R.layout.fragment_car_adapt,parent,false);
        return new ViewHolder(view);
    }

    @Override
    public void onBindViewHolder(@NonNull ViewHolder holder, int position) {
        Mine parking_lot = list.get(position);
        holder.tupian.setImageResource(parking_lot.getTupian());
        holder.Title.setText(parking_lot.getTitle());
        holder.kongwei.setText(parking_lot.getKongwei());
        holder.jiage.setText(parking_lot.getJiage());
        holder.dizhi.setText(parking_lot.getDizhi());
    }

    @Override
    public int getItemCount() {
        return list.size();
    }

    public class ViewHolder extends RecyclerView.ViewHolder {
        ImageView tupian;
        TextView Title,kongwei,jiage,jvli,dizhi;
        public ViewHolder(@NonNull View itemView) {
            super(itemView);
            tupian = itemView.findViewById(R.id.imageView);
            Title = itemView.findViewById(R.id.Title);
            kongwei = itemView.findViewById(R.id.kongwei);
            jiage = itemView.findViewById(R.id.jiage);
            jvli = itemView.findViewById(R.id.jvli);
            dizhi = itemView.findViewById(R.id.dizhi);

        }
    }

}